package interact;

import interact.click.AddNaturalSplineControlPoint;

import java.util.ArrayList;

import processing.core.PApplet;
import processing.core.PVector;
import remixlab.proscene.Camera;
import remixlab.proscene.Scene;
import co.edu.unal.cg.splines.interact.InteractiveCardinalSpline;
import co.edu.unal.cg.splines.interact.InteractiveHermiteSpline;
import co.edu.unal.cg.splines.interact.InteractiveNaturalSpline;
import co.edu.unal.cg.splines.interact.InteractiveSpline;

public class MyProcessingSketch extends PApplet {

	Scene scene;
	ArrayList<InteractiveSpline> splines = new ArrayList<InteractiveSpline>();
	
	Button2D addControlPoint;
	
	public void setup() {
		size(640, 360, P3D);
		// Scene instantiation
		scene = new Scene(this);
		scene.setCameraType(Camera.Type.ORTHOGRAPHIC);
		scene.setRadius(150);
		scene.showAll();
		
		InteractiveNaturalSpline interactiveNaturalSpline;
		InteractiveHermiteSpline interactiveHermiteSpline;
		InteractiveCardinalSpline interactiveCardinalSpline;	
		
		interactiveNaturalSpline = new InteractiveNaturalSpline(scene);
		interactiveNaturalSpline.addControlPoint(new PVector(0.1f, 0.1f, 1f));
		interactiveNaturalSpline.addControlPoint(new PVector(10, 10, 10));
		interactiveNaturalSpline.addControlPoint(new PVector(-10, 10, 10));
		interactiveNaturalSpline.addControlPoint(new PVector(-10, -10, 10));
		
		interactiveHermiteSpline =  new InteractiveHermiteSpline(scene);
		interactiveHermiteSpline.addControlPoint(new PVector(10.1f, 10.1f, 20f)); 
		interactiveHermiteSpline.addControlPoint(new PVector(10.1f, 10.1f, -20f));
		interactiveHermiteSpline.addControlPoint(new PVector(10.1f, -10.1f, 20f));
		interactiveHermiteSpline.addControlPoint(new PVector(-10.1f, 10.1f, 20f));
		
		interactiveCardinalSpline =  new InteractiveCardinalSpline(scene,0.5f);
		interactiveCardinalSpline.addControlPoint(new PVector(10.1f, 10.1f, 20f)); 
		interactiveCardinalSpline.addControlPoint(new PVector(10.1f, 10.1f, -20f));
		interactiveCardinalSpline.addControlPoint(new PVector(10.1f, -10.1f, 20f));
		interactiveCardinalSpline.addControlPoint(new PVector(-10.1f, 10.1f, 20f));
		interactiveCardinalSpline.addControlPoint(new PVector(-10.1f, 10.1f, 30f));
		interactiveCardinalSpline.addControlPoint(new PVector(-10.1f, -20.1f, 50f));
		
		splines.add(interactiveNaturalSpline);
		
		InteractiveNaturalSpline newSpline =new InteractiveNaturalSpline(scene);
		addControlPoint = new Button2D(scene, new PVector(10,10), "+",  new  AddNaturalSplineControlPoint(newSpline, this));
		
		splines.add(newSpline);
		
	}

	public void draw() {
		background(255);
		fill(0, 0, 0);
		
		for(InteractiveSpline spline : splines){
			spline.draw(this);
		}
		
		addControlPoint.draw(this);

	}
}